package com.zhdl.modules.prefiresys.repository;

import com.project.common.repository.BaseRepository;
import com.zhdl.modules.prefiresys.entity.DetectorAreaInfo;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;

/**
 * @Description:
 */
public interface DetectorAreaInfoRepository extends BaseRepository<DetectorAreaInfo, String> {
    /**
     * 根据防区序号列新名称和状态
     *
     * @param id
     * @param no
     * @param name
     * @return
     */
    @Modifying
    @Query("update DetectorAreaInfo dai set dai.areaName = :name, dai.status = :status where dai.detectorId = :id AND dai.areaNo = :no")
    int updateAreaByNo(@Param("id") String id, @Param("no") byte no, @Param("name") String name, @Param("status") boolean status);

    @Modifying
    @Transactional
    @Query("DELETE FROM DetectorAreaInfo b WHERE b.detectorId = :id")
    int deleteByDetectorId(String id);
}